﻿/********************************************************************************/
// <copyright file="NewsFactory.cs" company="Asia E-Business Solutions">
//     Copyright © 2012. All right reserved
// </copyright>
// <history>
//     <change who="Phuoc Le" date="24/12/2012 3:02:03 PM">Created</change>
// </history>
/********************************************************************************/

using System;
using System.Collections.Generic;
using LINQ = JLL.China.Infrastructure.Repositories.LINQ2SQL;

namespace JLL.China.Infrastructure.Repositories.News
{
    public static class NewsFactory
    {
        public static Model.News FromLINQObject(LINQ.NewsContent news)
        {
            if (news == null)
            {
                return null;
            }
            else
            {
                var model = new Model.News
                {
                    NewsId = news.NewsContent_ID,
                    LanguageFID = news.LanguageFID,
                    Title = news.Title,
                    Summary = news.NewSummary,
                    Content = news.NewContent,
                    Slug = news.Slug,
                    Status = news.Status,
                    Thumbnail = news.Thumbnail,
                    DateCreated = news.datecreated,
                    CreatedBy = news.createdby,
                    DateUpdated = news.dateupdated,
                    UpdatedBy = news.updatedby,
                    NewCategoryFID = news.NewCategoryFID
                };
                return model;
            }
        }

        public static LINQ.NewsContent ToLINQObject(Model.News news)
        {
            var model = new LINQ.NewsContent
            {
                NewsContent_ID = news.NewsId,
                NewCategoryFID = news.NewCategoryFID,
                Title = news.Title,
                NewSummary = news.Summary,
                NewContent = news.Content,
                Slug = news.Slug,
                Status = news.Status,
                Thumbnail = news.Thumbnail,
                datecreated = news.DateCreated,
                createdby = news.CreatedBy,
                dateupdated = news.DateUpdated,
                updatedby = news.UpdatedBy,
                LanguageFID = news.LanguageFID
            };
            return model;
        }
    }
}
